package tmproject.hlhj.fhp.cartrans.modules

import android.content.Context
import com.example.mymvp.BaseModule
import com.lzy.okgo.model.Response
import io.reactivex.disposables.Disposable
import tmproject.hlhj.fhp.cartrans.http.Apis
import tmproject.hlhj.fhp.cartrans.http.BaseAciton
import tmproject.hlhj.fhp.cartrans.http.LoadingAction
import tmproject.hlhj.fhp.cartrans.javaBean.BaseBean
import tmproject.hlhj.fhp.cartrans.javaBean.NoticeDetailBean

/**
 * Created by Never Fear   on 2018\8\28 0028.
Never More....
 */
class NoticeDetailModule :BaseModule {
    var listener:OnNoticeDetailListener?=null
    fun getNoticeDetail(c:Context,token:String?,id:Int){
        Apis.getNoticeDetail(token, id)
                ?.let {
                    it.doOnSubscribe(LoadingAction(c))
                            .subscribe(object :BaseAciton<Response<NoticeDetailBean>>{
                                override fun onSubscribe(d: Disposable) {

                                }

                                override fun httpSuccess(t: Response<NoticeDetailBean>) {
                                    listener?.gotNoticeDetail(t.body())
                                }

                                override fun httpErroCode(baseBean: BaseBean) {

                                }

                                override fun httpFailed(e: Throwable?) {
                                }
                            })
                }
    }
    interface OnNoticeDetailListener{
        fun gotNoticeDetail(noticeDetailBean: NoticeDetailBean)
    }
}